Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing stream_format params to user #2811

Conversation

Arun-Prasad-V
Copy link
Contributor

@Arun-Prasad-V Arun-Prasad-V commented Jul 12, 2023

The user can select the stream_format for all the video streams through below params:

  • rgb_camera.color_format
  • depth_module.depth_format
  • depth_module.infra_format
  • depth_module.infra1_format
  • depth_module.infra2_format

Run ros2 param describe <your_node_name> <param_name> command to know the list of formats supported by that particular stream.
Alternatively, run rs-enumerate-devices command to know the list of profiles supported by the sensors connected.

@Arun-Prasad-V Arun-Prasad-V marked this pull request as ready for review July 19, 2023 07:30

void VideoProfilesManager::registerVideoSensorProfileFormat(stream_index_pair sip)
{
if (sip == DEPTH)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these formats be hard coded? what will happen if different camera models support different default profiles?
can't we use liberalsense api to fetch/query the default profiles for each sip ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Will do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LibRealSense APIs gives the default profiles of color and depth streams only. Couldn't get those for Infra streams.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arun-Prasad-V,
can we query the device about default profiles for the given streams, and if default is not given, then to hard coded it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can query about default profiles and configure the format, if found. If not, maybe can we choose the first found format whose profile's resolution matches with depth stream? So that there won't be anything hard coded.

@Arun-Prasad-V Arun-Prasad-V marked this pull request as draft July 25, 2023 15:51
@Arun-Prasad-V Arun-Prasad-V marked this pull request as ready for review July 27, 2023 10:09
@SamerKhshiboun
Copy link
Collaborator

Arun, I tried testing this PR behavior.
Two things I noticed:
on every new run/launch of ros2 node, I'm getting this:

[realsense2_camera_node-1] [INFO] [1690716658.785760351] [camera.camera]: Set ROS param depth_module.profile to default: 848x480x30
[realsense2_camera_node-1] [WARN] [1690716658.786094187] [camera.camera]: re-enable the infra stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786197250] [camera.camera]: re-enable the infra1 stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786345386] [camera.camera]: re-enable the infra2 stream for the change to take effect.
[realsense2_camera_node-1] [INFO] [1690716658.794661608] [camera.camera]: Set ROS param rgb_camera.profile to default: 1280x720x30

Is this due to this change ?

Also, I left a comment about the parameters names.

found = true;
_formats[sip] = RS2_FORMAT_ANY;
}
else if (string_to_rs2_format(format_str , &temp_format))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this function name to be something more clear.
I expect it only to convert from string to rs2_format, but it return a Boolean that we need to check.
Or, maybe, change the design of these lines..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated the design of this function. Will return RS2_FORMAT_ANY if not found. Should I change the function name as well?

@Arun-Prasad-V
Copy link
Contributor Author

Arun, I tried testing this PR behavior. Two things I noticed: on every new run/launch of ros2 node, I'm getting this:

[realsense2_camera_node-1] [INFO] [1690716658.785760351] [camera.camera]: Set ROS param depth_module.profile to default: 848x480x30
[realsense2_camera_node-1] [WARN] [1690716658.786094187] [camera.camera]: re-enable the infra stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786197250] [camera.camera]: re-enable the infra1 stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786345386] [camera.camera]: re-enable the infra2 stream for the change to take effect.
[realsense2_camera_node-1] [INFO] [1690716658.794661608] [camera.camera]: Set ROS param rgb_camera.profile to default: 1280x720x30

Is this due to this change ?

Also, I left a comment about the parameters names.

Hi @SamerKhshiboun ,
This will happen if the default param set by RS ROS2 wrapper is different from the value set during run/launch.

It occurs not only for the new params, also for old params like "rgb_camera.profile" & "depth_module.profile".

@Arun-Prasad-V
Copy link
Contributor Author

Arun, I tried testing this PR behavior. Two things I noticed: on every new run/launch of ros2 node, I'm getting this:

[realsense2_camera_node-1] [INFO] [1690716658.785760351] [camera.camera]: Set ROS param depth_module.profile to default: 848x480x30
[realsense2_camera_node-1] [WARN] [1690716658.786094187] [camera.camera]: re-enable the infra stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786197250] [camera.camera]: re-enable the infra1 stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786345386] [camera.camera]: re-enable the infra2 stream for the change to take effect.
[realsense2_camera_node-1] [INFO] [1690716658.794661608] [camera.camera]: Set ROS param rgb_camera.profile to default: 1280x720x30

Is this due to this change ?
Also, I left a comment about the parameters names.

Hi @SamerKhshiboun , This will happen if the default param set by RS ROS2 wrapper is different from the value set during run/launch.

It occurs not only for the new params, also for old params like "rgb_camera.profile" & "depth_module.profile".

For example - In D455 model:

  • For Infra0 stream, there is no default profile. So, ROS2 wrapper set the format to 'UYVY' (first found).
    • But, rs_launch.py sets it to RGB8 format
    • Thus warning message from callback function

@SamerKhshiboun
Copy link
Collaborator

Arun, I tried testing this PR behavior. Two things I noticed: on every new run/launch of ros2 node, I'm getting this:

[realsense2_camera_node-1] [INFO] [1690716658.785760351] [camera.camera]: Set ROS param depth_module.profile to default: 848x480x30
[realsense2_camera_node-1] [WARN] [1690716658.786094187] [camera.camera]: re-enable the infra stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786197250] [camera.camera]: re-enable the infra1 stream for the change to take effect.
[realsense2_camera_node-1] [WARN] [1690716658.786345386] [camera.camera]: re-enable the infra2 stream for the change to take effect.
[realsense2_camera_node-1] [INFO] [1690716658.794661608] [camera.camera]: Set ROS param rgb_camera.profile to default: 1280x720x30

Is this due to this change ?
Also, I left a comment about the parameters names.

Hi @SamerKhshiboun , This will happen if the default param set by RS ROS2 wrapper is different from the value set during run/launch.
It occurs not only for the new params, also for old params like "rgb_camera.profile" & "depth_module.profile".

For example - In D455 model:

  • For Infra0 stream, there is no default profile. So, ROS2 wrapper set the format to 'UYVY' (first found).

    • But, rs_launch.py sets it to RGB8 format
    • Thus warning message from callback function

I understand this, so, in this case, the best thing I can think about is, to define 3 parameters for infra, as default formats
for infra1 and infra2 --> Y8
for infra0 rgb
so, dont take the first found, but takes these if not found.

@SamerKhshiboun
Copy link
Collaborator

LGTM

@SamerKhshiboun SamerKhshiboun merged commit 6a2a0fc into IntelRealSense:ros2-development Jul 31, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants